<template>
  <div>
    <div class="cmt_floor">
      <parent
        :parentData="parentData.parent"
        v-if="parentData.parent"
        @parentCallReply="parentCallReply"
      />

      <div class="cmt_content" @mouseenter="isReply=true" @mouseleave="isReply=false">
        <div class="cmt_info">
          {{parentData.account.nickname}}
          <i>{{parentData.created_at |itemDate}}</i>
          <span>{{parentData.level}}</span>
        </div>
        <p class="cmt_message">{{parentData.content}}</p>

        <div class="cmt_ctrl">
          <a href="javascript:;" v-show="isReply" @click="handleClick(parentData)">回复</a>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import moment from "moment";

export default {
  name: "parent",
  props: ["parentData"],
  data() {
    return {
      isReply: false
    };
  },
  mounted() {
    // console.log(this.parentData);
  },
  filters: {
    itemDate(e) {
      return moment(e).format("YYYY-MM-DD HH:mm");
    }
  },
  methods: {
    handleClick(parentData) {
      this.$emit("parentCallReply", parentData);
    },
    parentCallReply(parentData) {
      this.$emit("parentCallReply", parentData);
    }
  }
};
</script>
<style lang="less" scoped>
.cmt_floor {
  background: #f9f9f9;
  border: 1px solid #ddd;
  padding: 2px;
  .cmt_content {
    padding: 5px 10px 0;
    .cmt_info {
      margin-bottom: 10px;
      font-size: 12px;
      color: #666;
      i {
        color: #999;
      }
    }
    .cmt_ctrl {
      height: 20px;
      height: 20px;
      line-height: 20px;
      font-size: 12px;
      text-align: right;
      color: #1e50a2;
      a {
        text-decoration: none;
        color: inherit;
      }
    }
    span {
      float: right;
    }
  }
}
</style>